#ifndef __XKK_ACCEPTOR_H__
#define __XKK_ACCEPTOR_H__

#include "InetAddress.hpp"
#include "Socket.hpp"

namespace xkk
{

class Acceptor
{
public:
    Acceptor(unsigned short port);
    Acceptor(const string &ip,unsigned short port);
    void ready();

    int accept();
    int fd() const{ return _listenSock.fd(); }

private:
    void setReuseAddr(bool on);
    void setReusePort(bool on);
    void bind();
    void listen();

private:
    InetAddress _addr;
    Socket _listenSock;
};

}
#endif
